#! /usr/bin/make

PACKAGE = heroz
VERSION = 0.0.0

CXXFLAGS = -std=c++0x -Wall -g -O2 -fPIC `python-config --includes`
CFLAGS = -Wall -g -O2 -fPIC

prefix = $(DESTDIR)/usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
includedir = $(prefix)/include/R8B
libdir = $(exec_prefix)/lib
localstatedir = $(prefix)/var
datarootdir = $(prefix)/share
datadir = $(datarootdir)/$(PACKAGE)

.PHONY: all clean distclean examples install uninstall

all:	heroz libretro8.a basic framebasic screen_editor engine_test _heroengine.so

framebasic: bV2.o framebasic.o
	$(CXX) $(CXXFLAGS) -o $@ $+ -lSDL -lSGE

basic: bV2.o basicV1_5.o
	$(CXX) $(CXXFLAGS) -o $@ $+

libretro8.a:	$(OBJ)
	ar rcs libretro8.a $+

clean:
	rm -f *.o *.so *.hi *.a retro8Test *.x heroz? heroengine.py heroengine_wrap.cc


distclean:
	$(MAKE) clean
	rm -f heroengine_wrap.cc heroengine.py*

install:
	install -d $(includedir) $(libdir) $(datadir)

uninstall:
	rm -r $(datadir)
	rm -r $(includedir)
	#rm $(libdir)

heroz:	heroz.o guru_meditation.o heroz_graphics.o heroz_screens.o heroz_font.o heroz_basic.o heroz_sound.o heroz_input.o heroz_levels.o bV2.o heroz_play_the_game.o heroz_main.o fmemory.o
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ $+ -lSDL -lSDL_image -lSDL_mixer -lSGE 

screen_editor: screen_editor.o  heroz_screens.o heroz_font.o heroz_input.o
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ $+ -lSDL -lSDL_image -lfltk -lXext -lX11 -ldl -lpthread

engine_test: engine_test.o guru_meditation.o bV2.o fmemory.o heroz.o heroz_graphics.o heroz_screens.o heroz_font.o heroz_sound.o heroz_basic.o heroz_input.o heroz_levels.o
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ $+ -lSDL -lSDL_image -lSDL_mixer -lSGE -ldl -lpthread

_heroengine.so: guru_meditation.o bV2.o fmemory.o heroz.o heroz_graphics.o heroz_screens.o heroz_font.o heroz_sound.o heroz_basic.o heroz_input.o heroz_levels.o heroengine_wrap.o heroz_play_the_game.o
	$(CXX) -shared $(CXXFLAGS) $(CPPFLAGS) -o $@ $+  `python-config --libs` -lSDL -lSDL_image -lSDL_mixer -lSGE -ldl -lpthread

heroengine_wrap.cc: heroengine.i
	swig -o $@ -c++ -python $+
